#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <strings.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
	int x;
	struct in_addr addr;	//socket address
	uint32_t host_id;		//host id number
	uint32_t net_addr;

	const char *address[] = {
		"44.135.86.12",
		"127.0.0.1", 
		"172.16.23.95",
		"192.168.9.1"
	};

	for(x=0; x<4; x++) {
		bzero((char *) &addr, sizeof(addr));
		if( ! (host_id = inet_aton(address[x], &addr))) {
			fprintf(stderr, "ERROR: inet_ntoa");
			exit(1);
		}

		net_addr = inet_lnaof(addr);
		printf("Subnet of %16s : 0x%08d : 0x%08d\n", address[x], net_addr, htonl(net_addr));
	}

	return 0;
}
